"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const { exec } = require('child_process');
async function getBatteryReport() {
    const command = 'chcp 65001 && Powercfg/batteryreport';
    return new Promise((resolve, reject) => {
        exec(command, (error, stdout, stderr) => {
            if (error) {
                console.error(`错误: ${error.message}`);
                return null;
            }
            if (stderr) {
                console.error(`stderr: ${stderr}`);
                return null;
            }
            const result = stdout.split('\n');
            const pathLine = result[1].trim();
            const path = pathLine.substring(17, pathLine.length - 1);
            resolve(fs_1.default.readFileSync(path, 'utf8'));
        });
    });
}
exports.default = getBatteryReport;
